home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / libhtml_.tar / libwww / tcp.h < prev   
C/C++ Source or Header  |  1993-01-20  |  10KB  |  366 lines

  1. /*    System-system differences for TCP include files and macros     tcp.h
  2. **    ===========================================================
  3. **
  4. **
  5. **    This file includes for each system, the files necessary for
  6. **    network and file I/O
  7. **
  8. ** Authors
  9. **    TBL    Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
  10. **    EvA    Eelco van Asperen <evas@cs.few.eur.nl>
  11. **
  12. **  History:
  13. **    22 Feb 91    Written (TBL) as part of the WWW project.
  14. **    16 Jan 92    PC code from EvA
  15. */
  16. #ifndef TCP_H
  17. #define TCP_H
  18.  
  19. /* Default values of those: */
  20. #define NETCLOSE close        /* Routine to close a TCP-IP socket        */
  21. #define NETREAD  read        /* Routine to read from a TCP-IP socket    */
  22. #define NETWRITE write        /* Routine to write to a TCP-IP socket    */
  23.  
  24. /* Unless stated otherwise, */
  25. #define SELECT            /* Can handle >1 channel.        */
  26. #define GOT_SYSTEM        /* Can call shell with string        */
  27.  
  28. #ifdef unix
  29. #define GOT_PIPE
  30. #endif
  31. #ifdef VM
  32. #define GOT_PIPE        /* Of sorts */
  33. #endif
  34.  
  35. #ifdef DECNET
  36. typedef struct sockaddr_dn SockA;  /* See netdnet/dn.h or custom vms.h */
  37. #else /* Internet */
  38. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  39. #endif
  40.  
  41.  
  42. /*    Macintosh - Think-C
  43. **    -------------------
  44. **
  45. **    Think-C is one development environment on the Mac.
  46. **
  47. **    We recommend that you compile with 4-byte ints to be compatible
  48. **    with MPW C.  We used Tom Milligan's s_socket library which was
  49. **    written for 4 byte int, and the MacTCP library assumes 4-byte int.
  50. */
  51. #ifdef THINK_C
  52. #undef GOT_SYSTEM
  53. #define DEBUG            /* Can't put it on the CC command line    */
  54. #define NO_UNIX_IO        /* getuid() missing            */
  55. #define NO_GETPID        /* getpid() does not exist         */
  56. #define NO_GETWD        /* getwd() does not exist         */
  57.  
  58. #undef NETCLOSE            /* Routine to close a TCP-IP socket        */
  59. #undef NETREAD            /* Routine to read from a TCP-IP socket    */
  60. #undef NETWRITE         /* Routine to write to a TCP-IP socket    */
  61. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket        */
  62. #define NETREAD  s_read        /* Routine to read from a TCP-IP socket    */
  63. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket    */
  64.  
  65. #define bind s_bind        /* Funny names presumably to prevent clashes */
  66. #define connect s_connect
  67. #define accept s_accept
  68. #define listen s_listen
  69. #define socket s_socket
  70. #define getsockname s_getsockname
  71.  
  72. /* The function prototype checking is better than the include files
  73. */
  74.  
  75. extern s_close(int s);
  76. extern s_read(int s, char *buffer, int buflen);
  77. extern s_write(int s, const char *buffer, int buflen);
  78.  
  79. extern bind(int s, struct sockaddr *name, int namelen);
  80. extern accept(int s, struct sockaddr *addr, int *addrlen);
  81. extern listen(int s, int qlen);
  82. extern connect(int s, struct sockaddr *addr, int addrlen);
  83.  
  84. extern s_socket(int domain, int type, int protocol);
  85. extern s_getsockname(int s, struct sockaddr *name, int *namelen);
  86. extern struct hostent *gethostent(const char * name);
  87. extern unsigned long inet_addr(const char * name);
  88.  
  89. #endif /* THINK_C */
  90.  
  91.  
  92. #ifndef STDIO_H
  93. #include <stdio.h>
  94. #define STDIO_H
  95. #endif
  96.  
  97.  
  98. /*    On the IBM RS-6000, AIX is almost Unix.
  99. **    But AIX must be defined in the makefile.
  100. */
  101. #ifdef AIX
  102. #define unix
  103. #endif
  104.  
  105. /*    MVS is compiled as for VM. MVS has no unix-style I/O
  106. **    The command line compile options seem to come across in
  107. **    lower case.
  108. **
  109. **    See aslo lots of VM stuff lower down.
  110. */
  111. #ifdef mvs
  112. #define MVS
  113. #endif
  114.  
  115. #ifdef MVS
  116. #define VM
  117. #endif
  118.  
  119. #ifdef NEWLIB
  120. #pragma linkage(newlib,OS)    /* Enables recursive NEWLIB */
  121. #endif
  122.  
  123. /*    VM doesn't have a built-in predefined token, so we cheat: */
  124. #ifndef VM
  125. #include <string.h>        /* For bzero etc - not  VM */
  126. #endif
  127.  
  128.  
  129. /*    Under VMS, there are many versions of TCP-IP. Define one if you
  130. **    do not use Digital's UCX product:
  131. **
  132. **        UCX        DEC's "Ultrix connection" (default)
  133. **        WIN_TCP        From Wollongong, now GEC software.
  134. **        MULTINET    From SRI, now from TGV Inv.
  135. **        DECNET        Cern's TCP socket emulation over DECnet
  136. **
  137. **    The last three do not interfere with the unix i/o library, and so they
  138. **    need special calls to read, write and close sockets. In these cases the
  139. **    socket number is a VMS channel number, so we make the @@@ HORRIBLE @@@
  140. **    assumption that a channel number will be greater than 10 but a
  141. **    unix file descriptor less than 10.
  142. */
  143. #ifdef vms
  144. #ifdef WIN_TCP
  145. #undef NETREAD
  146. #undef NETWRITE
  147. #undef NETCLOSE
  148. #define NETREAD(s,b,l)    ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  149. #define NETWRITE(s,b,l)    ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  150. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  151. #endif
  152.  
  153. #ifdef MULTINET
  154. #undef NETCLOSE
  155. #undef NETREAD
  156. #undef NETWRITE
  157. #define NETREAD(s,b,l)    ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  158. #define NETWRITE(s,b,l)    ((s)>10 ? socket_write((s),(b),(l)) : \
  159.                 write((s),(b),(l)))
  160. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  161. #endif
  162.  
  163. #ifdef DECNET
  164. #undef SELECT  /* not supported */
  165. #undef NETREAD
  166. #undef NETWRITE
  167. #undef NETCLOSE
  168. #define NETREAD(s,b,l)    ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  169. #define NETWRITE(s,b,l)    ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  170. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  171. #endif /* Decnet */
  172.  
  173. /*    Certainly this works for UCX and Multinet; not tried for Wollongong
  174. */
  175. #ifdef MULTINET
  176. #include "multinet_root:[multinet.include.sys]types.h"
  177. #include "multinet_root:[multinet.include]errno.h"
  178. #include "multinet_root:[multinet.include.sys]time.h"
  179. #else
  180. #include types
  181. #include errno
  182. #include time
  183. #endif /* multinet */
  184.  
  185. #include string
  186.  
  187. #ifndef STDIO_H
  188. #include stdio
  189. #define STDIO_H
  190. #endif
  191.  
  192. #include file
  193.  
  194. #ifndef DECNET  /* Why is it used at all ? Types conflict with "types.h" */
  195. #include unixio
  196. #endif
  197.  
  198. #define INCLUDES_DONE
  199.  
  200. #ifdef MULTINET  /* Include from standard Multinet directories */
  201. #include "multinet_root:[multinet.include.sys]socket.h"
  202. #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
  203. #define __TIME  /* to avoid double definitions in next file */
  204. #endif
  205. #include "multinet_root:[multinet.include.netinet]in.h"
  206. #include "multinet_root:[multinet.include.arpa]inet.h"
  207. #include "multinet_root:[multinet.include]netdb.h"
  208.  
  209. #else  /* not multinet */
  210. #ifdef DECNET
  211. #include "types.h"  /* for socket.h */
  212. #include "socket.h"
  213. #include "dn"
  214. #include "dnetdb"
  215. /* #include "vms.h" */
  216.  
  217. #else /* UCX or WIN */
  218. #include socket
  219. #include in
  220. #include inet
  221. #include netdb
  222.  
  223. #endif  /* not DECNET */
  224. #endif  /* of Multinet or other TCP includes */
  225.  
  226. #define TCP_INCLUDES_DONE
  227.  
  228. #endif    /* vms */
  229.  
  230.  
  231. /*    IBM VM/CMS or MVS
  232. **    -----------------
  233. **
  234. **    Note:    All include file names must have 8 chars max (+".h")
  235. **
  236. **    Under VM, compile with "(DEF=VM,SHORT_NAMES,DEBUG)"
  237. **
  238. **    Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
  239. **      System include files TCPIP and COMMMAC neeed line number removal(!)
  240. */
  241.  
  242. #ifdef VM            /* or MVS -- see above. */
  243. #define NOT_ASCII        /* char type is not ASCII */
  244. #define NO_UNIX_IO        /* Unix I/O routines are not supported */
  245. #define NO_GETPID        /* getpid() does not exist */
  246. #define NO_GETWD        /* getwd() does not exist */
  247. #ifndef SHORT_NAMES
  248. #define SHORT_NAMES        /* 8 character uniqueness for globals */
  249. #endif
  250. #include <manifest.h>                                                           
  251. #include <bsdtypes.h>                                                           
  252. #include <stdefs.h>                                                             
  253. #include <socket.h>                                                             
  254. #include <in.h>
  255. #include <inet.h>
  256. #include <netdb.h>                                                                 
  257. #include <errno.h>        /* independent */
  258. extern char asciitoebcdic[], ebcdictoascii[];
  259. #define TOASCII(c)   (c=='\n' ?  10  : ebcdictoascii[c])
  260. #define FROMASCII(c) (c== 10  ? '\n' : asciitoebcdic[c])                                   
  261. #include <bsdtime.h>
  262. #include <time.h>
  263. #include <string.h>                                                            
  264. #define INCLUDES_DONE
  265. #define TCP_INCLUDES_DONE
  266. #endif
  267.  
  268.  
  269. /*    IBM-PC running MS-DOS with SunNFS for TCP/IP
  270. **    ---------------------
  271. **
  272. **    This code thanks to Eelco van Asperen <evas@cs.few.eur.nl>
  273. */
  274.  
  275. #ifdef PCNFS
  276. #include <sys/types.h>
  277. #include <string.h>
  278.  
  279.  
  280. #include <errno.h>        /* independent */
  281. #include <sys/time.h>        /* independent */
  282. #include <sys/stat.h>
  283. #include <fcntl.h>        /* In place of sys/param and sys/file */
  284. #define INCLUDES_DONE
  285.  
  286. #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |=  (1<<(fd))
  287. #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
  288. #define FD_ZERO(pmask)   (*(unsigned*)(pmask))=0
  289. #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
  290. #endif  /* PCNFS */
  291.  
  292.  
  293. /*    Regular BSD unix versions:    (default)
  294. **    -------------------------
  295. */
  296.  
  297. /* Mips hack (bsd4.3/sysV mixture...) */
  298. #ifdef mips
  299. extern int errno;
  300. #endif
  301.  
  302. #ifndef INCLUDES_DONE
  303. #include <sys/types.h>
  304. /* #include <streams/streams.h>            not ultrix */
  305. #include <string.h>
  306.  
  307. #include <errno.h>        /* independent */
  308. #include <sys/time.h>        /* independent */
  309. #include <sys/stat.h>
  310. #include <sys/param.h>
  311. #include <sys/file.h>        /* For open() etc */
  312. #define INCLUDES_DONE
  313. #endif    /* Normal includes */
  314.  
  315. #ifdef unix                    /* if this is to compile on a UNIX machine */
  316. #include <sys/dir.h>
  317. #define GOT_READ_DIR 1    /* if directory reading functions are available */
  318. #endif
  319.  
  320. /*    Default include files for TCP
  321. */
  322. #ifndef TCP_INCLUDES_DONE
  323. #include <sys/socket.h>
  324. #include <netinet/in.h>
  325. #include <arpa/inet.h>        /* Must be after netinet/in.h */
  326. #include <netdb.h>
  327. #endif    /* TCP includes */
  328.  
  329.  
  330. /*    Default macros for manipulating masks for select()
  331. */
  332. #ifdef SELECT
  333. #ifndef FD_SET
  334. typedef unsigned int fd_set;
  335. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  336. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  337. #define FD_ZERO(pmask)   (*(pmask))=0
  338. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  339. #endif  /* FD_SET */
  340. #endif  /* SELECT */
  341.  
  342. /*    Default macros for converting characters
  343. **
  344. */
  345. #ifndef TOASCII
  346. #define TOASCII(c) (c)
  347. #define FROMASCII(c) (c)                                   
  348. #endif
  349.  
  350. /* Removed to HTUtils on Ed V's suggestion
  351. */
  352. #ifdef OLD_CODE
  353. #ifndef TOLOWER
  354. #if defined(pyr) || defined(mips)
  355.   /* Pyramid and Mips can't uppercase non-alpha */
  356. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  357. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  358. #else
  359. #define TOLOWER(c) tolower(c)
  360. #define TOUPPER(c) toupper(c)
  361. #endif /* pyr || mips */
  362. #endif /* ndef TOLOWER */
  363. #endif /* OLD_CODE */
  364.  
  365. #endif /* TCP_H */
  366.